package simulation;

import java.util.List;

import persistence.PersistenceManagerImp;
import persistence.PersistenceManager;
import resources.ResourceProvider;

import model.EmailImp;

/**
 * Simulator Email Server
 */
public class SimulateEmailServer
{
   private static PersistenceManagerImp pers = new PersistenceManager(); 
   
   /**
    * send Email to the Client
    * @param email
    */
   public static void sendEmailToClient(EmailImp email)
   {
       List<String> recepients = email.getReceiver();
       for(String reciever : recepients)
       {
           boolean isRegistered = pers.isEmailIdRegistered(reciever);
           if(isRegistered)
           {
               String persistPath = ResourceProvider.getRootFolderPath(ResourceProvider.INBOX, reciever);
               pers.persistEMail(email, persistPath);
           }
       }
   }
}
